import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}
const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'Home',
    component: () => import('@/views/home')
  },
  {
    path: '/process',
    name: 'Process',
    component: () => import('@/views/process')
  },
  {
    path: '/news',
    name: 'News',
    component: () => import('@/views/news')
  },
  {
    path: '/newsDetail',
    name: 'NewsDetail',
    component: () => import('@/views/newsDetail')
  },
  {
    path: '/about',
    name: 'About',
    component: () => import('@/views/about')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
